<template>
  <el-dialog
    title="印章申请（个人）"
    :visible.sync="dialogVisiblePerson"
    width="534px"
    :before-close="handleClose"
    :show-close="true"
  >
    <div class="company-box">
      <el-form
        :model="dataForm"
        :rules="dataRules"
        ref="dataForm"
        label-width="140px"
        class="demo-ruleForm"
      >
        <el-form-item label="姓名" prop="realName">
          <el-input
            v-model="dataForm.realName"
            placeholder="请输入姓名"
          ></el-input>
        </el-form-item>
        <el-form-item label="身份证号" prop="cardId">
          <el-input
            v-model="dataForm.cardId"
            placeholder="请输入身份证号"
          ></el-input>
        </el-form-item>
      </el-form>
    </div>
    <span slot="footer" class="prompts-one-footer dialog-footer">
      <el-button @click="dialogVisiblePerson = false">取 消</el-button>
      <el-button type="primary" @click="submitFormPerson('dataForm')"
        >申请</el-button
      >
    </span>
  </el-dialog>
</template>
<script>
import { isCardID } from "../plugins/validate";
export default {
  data() {
          var cardValidate = (rule, value, callback) => {
      isCardID(rule, value, callback);
    };
    return {
      dataRules: {
        realName: [{ required: true, message: "请输入姓名", trigger: "blur" }],
        cardId: [{ validator: cardValidate, trigger: "blur", required: true }],
      },
      dataForm: {
        username: "",
        cardId: "",
      },
      dialogVisiblePerson:false
    };
  },
  methods:{

    submitFormPerson(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
         this.$http("post",'/sys/esign/addPersonAccount.do',this.ruleForm).then(res=>{
              if (res.code =='0000') {
                this.$message({
                  type:'success',
                  message:"操作成功"
                })
                this.dialogVisiblePerson = false
                this.$emit('upDate')
              }
            })
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    init () {
        this.dialogVisiblePerson = true
    },
    handleClose () {
      this.dialogVisiblePerson = false
        this.$emit('upDate')
    }
  }
};
</script>
<style >
.company-box .el-input__inner {
  background: #f6f6f6;
  width: 296px;
}
.company-box .el-input__icon {
  color: #ee781b;
}
.company-box .el-form-item__label {
  color: #272727;
}
.company-box .el-button--primary {
  width: 145px;
  height: 38px;
  background: #ee781b;
  border-radius: 2px;
  border: 0;
  margin-top: 10px;
}
.prompts-one-footer .el-button--primary {
  width: 65px;
  height: 32px;
  background: #ee781b;
  border-radius: 2px;
  border: 0;
  padding: 0;
}
.prompts-one-footer .el-button--default {
  width: 65px;
  height: 32px;
  background: #ffffff;
  border-radius: 2px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  padding: 0;
}
</style>